<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<title>医联体</title>
<style type="text/css">

</style>
</head>
<script type="text/javascript">
 $(function() {
	$(this).registerManagerPage();
 	initView();
});

function queryForm() {
	$("#yltTable").datagrid("reload");
}

function initView()
{
	/**加载值域*/
	//$(".cacheTable").CacheForSelect();
	initDatagrid();
	$("#queryForm").attr("action","queryYlt");
	/**确认按钮*/
	$("#enter").on("click", function(){
		var row = $("#yltTable").datagrid("getSelected");
		if(validateYlt(row)){
			/**查询医联体所有信息*/
			$.QuickRemote.AjaxFiledFormSubmit("queryForm", function(result) { 
					StoreCache.setCache("QYSQ_YLTXX", result);
					parent.layer.closeAll("iframe");
			}, {YLTID: row["YLTID"]});
		}
	});
	/**关闭按钮*/
	$("#close").on("click", function(){
		parent.layer.closeAll("iframe");
	});
}

function initDatagrid(){
	var cache = StoreCache.removeCache("QYSQ_YLTXX");
	var opt = {
				idField : "YLTID",
				uniqueId : "YLTID",
				striped : true,
				columns : [ [ 
				{
					field : "YLTMC",
					width : 200,
					align : "center",
					title : "医联体名称"
				}, {
					field : "YLTLXMC",
					width : 150,
					align : "center",
					title : "医联体类型"
				}, {
					field : "ZDYLJGMC",
					width : 200,
					align : "center",
					title : "主导机构"
				}, {
					field : "CJSJ",
					width : 150,
					align : "center",
					title : "创建时间"
				}/* ,{
					field : "cz",
					width : 100,
					align : "center",
					title : "操作",
					formatter : function(value, row, index){
						return ($("#yltDetail").html()).replace(/#yltid#/g,row["YLTID"]);
					}
				}  */] ],
				pagination : true,
				pageNumber : 1,
				pageSize : 10,
				fit : true,
				fitColumns : true,
				singleSelect : true,
				rownumbers : true,
				method : "post",
				url : "queryYltlb.service",
				onBeforeLoad : function(params)//加载之前回调 获取查询条件
				{
					params["YLTMC"] = $("#YLTMC").val();
					params["YLTLX"] = $("#YLTLX").val();
					params["YLJGID"] = cache["YLJGID"];
					params["YLTZT"] = "1";
					params["ZDYLJGMC"] = $("#ZDYLJGMC").val();
					return params;
				},onLoadSuccess: function(data){ 
					/**选中已选行*/
					var yltid = cache["YLTID"];
					if(!StringUtils.isEmpty(yltid)){
						$("#yltTable").datagrid("selectRecord",yltid);
					}
				}
			};
	/**加载机构*/
	$("#yltTable").datagrid(opt);
}

/**机构详情*/
function yltDetail(yltid){
	window.open("detail?YLTID="+ yltid);
}

/**查询按钮*/
function btnQueryHandler(){
	queryDatagrid();
}

/**刷新datagrid*/
function queryDatagrid(){
	$("#yltTable").datagrid("reload");
}

/**校验是否选择医联体*/
function validateYlt(row){
	var flag = false;
	if(StringUtils.isEmpty(row)){
		$.QuickAlert.alertFail({
			content : "请选择医联体！",
		});
	}else{
		flag = true;
	}
	return flag 
}
</script>

<body>
<div class="easyui-layout" fit="true" style="width: 100%;">
	<!-- <div region="north" style="border: none; overflow: hidden;">
	<h4 class="h4-title" style="font-size: 18px;">
		
	</h4>
	</div> -->
	<div region="center" style="border: none;overflow: hidden;">
	<div class="easyui-layout" style="width:100%;border: none;height: 400px;" fit="true" id='dataGridDiv'>
		<div region="north" style="border: none;overflow: hidden;">
			<form id="queryForm"></form>
			<div id="dgFormToolbar" style="background: white;">
				<table class="form-table" style="">
					<tr>
						<td class="td-text">医联体名称：</td>
						<td class="td-content">
							<input id="YLTMC" type="text" placeholder="医联体名称">
						</td>
						<td class="td-text">医联体类型：</td>
						<td class="td-content">
							<select id="YLTLX" class="form-control dataField " style="width:90%;"
								cacheTable="TB_ZY_YLTLX">
							</select>
						</td>
						<td class="td-text">主导机构名称：</td>
						<td class="td-content">
							<input id="ZDYLJGMC" type="text" placeholder="主导机构名称">
						</td>
						<td class="td-text">
							<button class="btn btn-default" type="button"
							onclick="btnQueryHandler()">查询</button>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div region="center" style="border: none;height: 300px">
			<table id="yltTable">
			</table> 
		</div>
	</div>
	</div>
	<div region="south" style="border: none;">
		<div style="float:right;height: 30px;margin-right: 10px;">
			<button type="button" id="enter">确认</button>
			&nbsp;
			<button type="button" id="close">关闭</button>
		</div>
	</div>
</div>
</body>
<script type="text/html" id="yltDetail">
<a href="javascript:yltDetail('#yltid#')" title="详细" >详细</a>
</script>
</html>



